//
//  FirstTableViewCell.m
//  UI_lesson_12_UITableViewCellHeight
//
//  Created by lanou3g on 16/3/2.
//  Copyright © 2016年 lanou3g. All rights reserved.
//

#import "FirstTableViewCell.h"
#import "FirstModel.h"
#import "Tool.h"
@implementation FirstTableViewCell

- (void)awakeFromNib {
    // Initialization code
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        self.showTextLable = [[UILabel alloc] initWithFrame:CGRectZero];
        [self.contentView addSubview:self.showTextLable];
        
        self.showImageView = [[UIImageView alloc] initWithFrame:CGRectZero];
        [self.contentView addSubview:self.showImageView];
    }
    
    return self;
}
- (void)layoutSubviews{
    //设置空间的frame和数据
    CGFloat lableHeight = [Tool lableHeightWithText:self.model.text font:self.showTextLable.font];
    self.showTextLable.frame = CGRectMake(0, 0, [[UIScreen mainScreen] bounds].size.width, lableHeight);
    self.showTextLable.numberOfLines = 0;
    self.showTextLable.text = self.model.text;
    
    
    CGFloat imageHeight = [Tool imageScaleHeightWith:self.model.imageName];
    self.showImageView.frame = CGRectMake(0, lableHeight , [[UIScreen mainScreen] bounds].size.width, imageHeight);
    
    self.showImageView.image = [UIImage imageNamed:self.model.imageName];
    
    
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
